import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;

/**
 * @Title: 天梯赛的善良
 * @Author 贾金博
 * @Package PACKAGE_NAME
 * @Date 2024/3/8 14:05
 * @description:
 */
public class 天梯赛的善良 {
    public static void main(String[] args) throws IOException {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        Map<Integer, Integer> mp = new HashMap<>();

        for(int i = 0; i < n; ++ i ) {
            a[i] = sc.nextInt();
            mp.merge(a[i], 1, Integer::sum);
        }
        Arrays.sort(a);
        System.out.println(a[0] + " " + mp.get(a[0]));
        System.out.println(a[n - 1] + " " + mp.get(a[n - 1]));

    }
}
